package com.auxgroup.smarthome.enterpriseapi.locations;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * Created by kevinchen on 2017/3/25.
 */
public class LocationsCountBean {
    private int total;
    private List<CountryCountBean> countryCounts;

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    public List<CountryCountBean> getCountryCounts() {
        return countryCounts;
    }

    public void setCountryCounts(List<CountryCountBean> countryCounts) {
        this.countryCounts = countryCounts;
    }

    public LocationsCountBean() {
    }

    public LocationsCountBean(int total) {
        this.total = total;
    }

    public void addCountryCountBean(CountryCountBean countryCountBean){
        if (countryCounts == null){
            this.countryCounts = new ArrayList<>();
        }
        countryCounts.add(countryCountBean);
    }

    /**
     * 兼容前端 不然返回空数据 前端不处理
     * @return
     */
    public List<RegionCountBean> getChinaRegionCountList(){
        if (countryCounts == null)return null;
        for(Iterator<CountryCountBean> iterator = countryCounts.iterator();iterator.hasNext();){
            CountryCountBean next = iterator.next();
            if ("Unknown".compareTo(next.getCountryEn())==0){
                continue;
            }
            if ("China".compareTo(next.getCountryEn())==0){
                return next.getRegionCounts();
            }
        }
        return new ArrayList<RegionCountBean>();
    }
}
